package com.srv.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.srv.TheException;
import com.srv.model.ID;
import com.srv.model.User;
import com.srv.model.json.Node_Json4Owner;
import com.srv.service.IDService;
import com.srv.service.NodeService;

public class ServletNodeList extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 12333333333L;
	private static Log log = LogFactory.getLog(ServletNodeList.class);
	public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException {
	try{
		response.setContentType(ConstText.TextHtml);
		ResponseResult result = new ResponseResult();
		User theUser = RequestTool.getAccessUser(request);			
		//未登陆
		if(theUser==null){				
			result.theResult = ResponseResult.RESULT_FAIL;//结果失败
			result.theMessageObj = ConstText.NotLogin;	
			ResponseTool.repsone(request,response,result);
			return;
		}
		 //参数检查，id为travel的id
		 String tid = RequestTool.getValueOfID(request);		 		 
		 //检查ID是否合法
		 ID idObj = IDService.getID(tid);
		 if(idObj==null){
			 result.theResult = ResponseResult.RESULT_FAIL;//结果失败
			 result.theMessageObj=ConstText.ID_IS_INVALID;
			 ResponseTool.repsone(request,response,result);
			 return;		 
		 }	     
	     result.theMessageObj = Node_Json4Owner.convert(NodeService.list(tid));
	     ResponseTool.repsone(request,response,result);
	}catch(TheException te){
		log.error(te.getMessage());
	}
	}

}
